# -*- encoding: utf-8 -*-
'''
@File    :   1.py
@Time    :   2022/11/29 10:58:06
@Author  :   Cms 
@Version :   1.0
@Contact :   2267000140@qq.com
@WebSite    :   www.baidu.com
'''

# here put the import lib
import random
import time
import threading

from concurrent.futures import ThreadPoolExecutor
# 1  有100个同学的分数：数据请用随机函数生成；
#      A  利用多线程程序（比如，5个线程，每个线程负责输出20条记录），快速输出这100个同学的信息；
#      B 利用线程池来实现；

def print_score():
    for i in range(20):
        x = random.randint(0,100)
        print(x)
    time.sleep(1)

# A 多线程
# for i in range(5):
#     t = threading.Thread(target=print_score)
#     t.start()   #启动线程


# B 线程池
threadPool = ThreadPoolExecutor(max_workers=5)
for i in range(5):
    future = threadPool.submit(print_score)
threadPool.shutdown(wait=True)